﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IsmlTools.Common
{
    public class RegHelper
    {
        public static string GetMidPattern(string begin, string end)
        {
            return @"(?<=" + begin + @")[.\s\S]*?(?=" + end + ")";
        }
    }

    public class LanguageCode
    {
        public const string En = "en";
        public const string Jp = "ja";
        public const string Kr = "ko";
        public const string Ru = "ru";
        public const string Sc = "zh-CN";
        public const string Tc = "zh-TW";
        public static readonly string[] AllLanguage = { En, Jp, Kr, Ru, Sc, Tc };
    }

    public class SeasonTitle
    {
        public static readonly Dictionary<int, string> YearMapName = new Dictionary<int, string>()
            {
                {2008, "2008年国际最萌大会"},{2009,"2009年国际最萌大会"},{2010,"2010年国际最萌大会"},{2011,"2011年国际最萌大会"},{2012,"2012年国际最萌大会"},{2013,"2013年国际最萌大会"}
            };
    }

    public class WebPageLink
    {
        // 2009
        public const string NamesSeason2009 = @"http://2009.internationalsaimoe.com/files/translation.js";

        // 2010
        public const string NamesSeason2010 = @"http://2010.internationalsaimoe.com/files/trans_names.js";

        // 2011    
        public const string NamesSeason2011 = @"http://2011.internationalsaimoe.com/files/names_season.js";
        public const string PreliminaryPhaseI2011 = @"http://2011.internationalsaimoe.com/statistics/preliminary/phase1.php";
        public const string PreliminaryPhaseIi2011 = @"http://2011.internationalsaimoe.com/statistics/preliminary/phase2.php";
        public const string PreliminaryPhaseIii2011 = @"http://2011.internationalsaimoe.com/statistics/preliminary/phase3.php";
        public const string Seeding2011 = @"http://2011.internationalsaimoe.com/statistics/preliminary/seeding.php";
        public const string Aquamarine2011 = @"http://2011.internationalsaimoe.com/statistics/aquamarine/index.php";
        public const string Topaz2011 = @"http://2011.internationalsaimoe.com/statistics/topaz/index.php";
        public const string Amethyst2011 = @"http://2011.internationalsaimoe.com/statistics/amethyst/index.php";
        public const string Sapphire2011 = @"http://2011.internationalsaimoe.com/statistics/sapphire/index.php";
        public const string Emerald2011 = @"http://2011.internationalsaimoe.com/statistics/emerald/index.php";
        public const string Ruby2011 = @"http://2011.internationalsaimoe.com/statistics/ruby/index.php";
        public const string Diamond2011 = @"http://2011.internationalsaimoe.com/statistics/diamond/index.php";
        public const string Elimination2011 = @"http://2011.internationalsaimoe.com/statistics/elimination/index.php";

        // 2012       
        public const string NamesSeason2012 = @"http://2012.internationalsaimoe.com/files/names_season.js";
        public const string PreliminaryPhaseI2012 = @"http://2012.internationalsaimoe.com/statistics/preliminary/phase1.php";
        public const string Seeding2012 = @"http://2012.internationalsaimoe.com/statistics/preliminary/seeding.php";
        public const string PreliminaryPhaseIi2012 = @"http://2012.internationalsaimoe.com/statistics/preliminary/phase2.php";
        public const string PreliminaryPhaseIii2012 = @"http://2012.internationalsaimoe.com/statistics/preliminary/phase3.php";
        public const string Aquamarine2012 = @"http://2012.internationalsaimoe.com/statistics/aquamarine/index.php";
        public const string Amethyst2012 = @"http://2012.internationalsaimoe.com/statistics/amethyst/index.php";
        public const string Ruby2012 = @"http://2012.internationalsaimoe.com/statistics/ruby/index.php";
        public const string Emerald2012 = @"http://2012.internationalsaimoe.com/statistics/emerald/index.php";
        public const string Topaz2012 = @"http://2012.internationalsaimoe.com/statistics/topaz/index.php";
        public const string Elimination2012 = @"http://2012.internationalsaimoe.com/statistics/elimination/index.php";

        // 2013
        public const string NamesSeason2013 = @"http://www.internationalsaimoe.com/files/names_season.js";
        public const string PreliminaryPhaseI2013 = @"http://www.internationalsaimoe.com/statistics/preliminary/phase1.php";
        public const string PreliminaryPhaseIi2013 = @"http://www.internationalsaimoe.com/statistics/preliminary/phase2.php";
        public const string PreliminaryPhaseIii2013 = @"http://www.internationalsaimoe.com/statistics/preliminary/phase3.php";
        public const string Aquamarine2013 = @"http://www.internationalsaimoe.com/statistics/aquamarine/index.php";
    }

    public class CalendarHelper
    {
        // 2011
        public static readonly DateTime PreliminaryPhaseIDate2011 = new DateTime(2011, 2, 27);
        public static readonly DateTime PreliminaryPhaseIiDate2011 = new DateTime(2011, 3, 17);
        public static readonly DateTime PreliminaryPhaseIiiDate2011 = new DateTime(2011, 3, 27);
        public static readonly DateTime Seeding2011 = new DateTime(2011, 4, 3);
        public static readonly DateTime Aquamarine2011 = new DateTime(2011, 4, 24);
        public static readonly DateTime Topaz2011 = new DateTime(2011, 5, 17);
        public static readonly DateTime Amethyst2011 = new DateTime(2011, 6, 12);
        public static readonly DateTime Sapphire2011 = new DateTime(2011, 7, 5);
        public static readonly DateTime Emerald2011 = new DateTime(2011, 7, 31);
        public static readonly DateTime Ruby2011 = new DateTime(2011, 8, 23);
        public static readonly DateTime Diamond2011 = new DateTime(2011, 9, 18);
        public static readonly DateTime Elimination2011 = new DateTime(2011, 10, 30);

        // 2012
        public static readonly DateTime PreliminaryPhaseIDate2012 = new DateTime(2012, 2, 12);
        public static readonly DateTime Seeding2012 = new DateTime(2012, 2, 26);
        public static readonly DateTime PreliminaryPhaseIiDate2012 = new DateTime(2012, 3, 11);
        public static readonly DateTime PreliminaryPhaseIiiDate2012 = new DateTime(2012, 4, 8);
        public static readonly DateTime Aquamarine2012 = new DateTime(2012, 5, 6);
        public static readonly DateTime Amethyst2012 = new DateTime(2012, 6, 3);
        public static readonly DateTime Ruby2012 = new DateTime(2012, 7, 1);
        public static readonly DateTime Emerald2012 = new DateTime(2012, 8, 29);
        public static readonly DateTime Topaz2012 = new DateTime(2012, 8, 26);
        public static readonly DateTime Elimination2012 = new DateTime(2012, 9, 30);

        // 2013
        public static readonly DateTime PreliminaryPhaseIDate2013 = new DateTime(2012, 2, 3);
        public static readonly DateTime PreliminaryPhaseIiDate2013 = new DateTime(2012, 3, 3);
        public static readonly DateTime PreliminaryPhaseIiiDate2013 = new DateTime(2012, 3, 17);
        public static readonly DateTime Aquamarine2013 = new DateTime(2012, 4, 14);

        public static DateTime GetNextDate(DateTime dateTime)
        {

            if (dateTime.DayOfWeek == DayOfWeek.Thursday)
                return dateTime.AddDays(3);
            else
                return dateTime.AddDays(2);

        }
    }

    public class MapHelper
    {
        public static readonly List<NCode> Node2011 = new List<NCode> {new NCode("Canada",117,50),
                                     new NCode("China",655,148),
                                     new NCode("Russia",616,52),
                                     new NCode("USA",106,109),
                                     new NCode("Africa",383,186),
                                     new NCode("SouthAmerica",210,291),
                                     new NCode("EastEurope",529,117),
                                     new NCode("Japan",722,133),
                                     new NCode("WesternEurope",379,97),
                                     new NCode("Australia",753,327),
                                     new NCode("Korea",687,120),
                                     new NCode("Taiwan",689,171),
                                     new NCode("CentralEurope",422,106),
                                     new NCode("Vietnam",633,187),
                                     new NCode("Indonesia",680,247),
                                     new NCode("Philippines",707,222),
                                     new NCode("HongKong",671,176) };
        public static readonly List<NCode> Node2012 = new List<NCode> {new NCode("Canada",120,70),
                                     new NCode("China",640,140),
                                     new NCode("Russia",580,60),
                                     new NCode("USA",100,120),
                                     new NCode("Africa",420,230),
                                     new NCode("SouthAmerica",200,280),
                                     new NCode("EastEurope",530,140),
                                     new NCode("Japan",722,132),
                                     new NCode("WesternEurope",300,20),
                                     new NCode("Australia",730,330),
                                     new NCode("Korea",695,132),
                                     new NCode("Taiwan",688,172),
                                     new NCode("CentralEurope",420,100),
                                     new NCode("Vietnam",654,204),
                                     new NCode("Thailand",640,200),
                                     new NCode("Indonesia",678,247),
                                     new NCode("Philippines",706,222),
                                     new NCode("HongKong",671,176),
                                     new NCode("Malaysia",684,230) };
        public Dictionary<string, int> EmptyMapRank = new Dictionary<string, int>(){
            {"Canada", 0}, 
            {"China", 0}, 
            {"Russia", 0},
            {"USA", 0},
            {"Africa", 0},
            {"SouthAmerica", 0},
            {"EastEurope", 0},
            {"Japan", 0},
            {"WesternEurope", 0},
            {"Australia", 0},
            {"Korea", 0},
            {"Taiwan", 0},
            {"CentralEurope", 0},
            {"Vietnam", 0},
            {"Thailand", 0},
            {"Indonesia", 0},
            {"Philippines", 0},
            {"HongKong", 0},
            {"Malaysia", 0}
        };
        public static readonly Dictionary<int, int> ColorMappling2011 = new Dictionary<int, int>(){
            {-1413310, -1}, 
            {-1413566, -1},
            {-12403222, 1},
            {-12337685, 1}, 
            {-6908266, 0}
        };

        public static readonly Dictionary<int, int> ColorMappling2012 = new Dictionary<int, int>(){
            {-2887721, 1}, 
            {-5119303, 2}, 
            {-7416166, 3},
            {-9647748, 4},
            {-11944867, 5},
            {-8504, -1},
            {-14946, -2},
            {-21645, -3},
            {-28087, -4},
            {-34530, -5},
            {-460552, 0}
        };
    }

    public class NCode
    {
        public string Code { get; set; }
        public int X { get; set; }
        public int Y { get; set; }


        public NCode(string code, int x, int y)
        {
            Code = code;
            X = x;
            Y = y;
        }
    }
}
